//
//  TTButton.swift
//  BaseModule_Example
//
//  Created by seven on 2020/7/2.
//  Copyright © 2020 CocoaPods. All rights reserved.
//

import UIKit

public class TTButton: UIButton {

//    ///  当文字为空的时候，隐藏图片
//    var hideImageViewWhenTitleEmpty: Bool = false
    ///  图片与文字的距离
    public var margin: Int = 0
    
    override public func layoutSubviews() {
        super.layoutSubviews()

        guard let imageView = self.imageView, let titleLabel = self.titleLabel else {
            return
        }
        if imageView.x < titleLabel.x {
            titleLabel.x = imageView.x
            imageView.x = titleLabel.maxX + CGFloat((margin == 0 ? 5 : margin))
        }
    }

}
